package com.hellloop.pim.alphabeat.network;

import java.util.StringTokenizer;

public class PIMGameMsg extends PIMMessage{	
	//<RoomId>
	public static int SentenseRequest = 1;
	
	public static int UserListRequest = 2;
	public static int UserListResponse = 3;
	//<Sentense>
	public static int SentenceResponse = 4;
	
	
	String _roomId;
	String _roomName;
	String _sentenses;
	
	public PIMGameMsg() {
		setMsgType( MsgType.GameMsg );
		//should set the messages argument match with the oprType
	}
	
	public PIMGameMsg(int oprType, String message ){
		setMsgType( MsgType.GameMsg );
		setOprType( oprType );
		
		StringTokenizer st = new StringTokenizer(message, ":");
		try {
			if( _oprType == PIMGameMsg.SentenseRequest ) {
				_roomId = st.nextToken();
			}
			else if( _oprType == PIMGameMsg.UserListRequest ) {

			}
		}
		catch(Exception e) {
			System.err.println("Error PIMMessage Format-PIMGameMsg");
			_message = message;
		}
	}
	
	public String toString() {
		StringBuffer buff = new StringBuffer();
		buff.append( getMsgType() ).append(":");
		buff.append( getOprType() ).append(":");
		
		if( _oprType == PIMGameMsg.SentenseRequest) {
			buff.append( _roomId ); 
		}
		else if( _oprType == PIMGameMsg.SentenceResponse  ) {
			buff.append( _sentenses );
		}
		
		return buff.toString();
	}
	
	public void setRoomId(String roomId) {
		_roomId = roomId;
		setMessage(_roomId);
	}
	
	public void setSentenses(String sentenses) {
		_sentenses = sentenses;
		setMessage(_sentenses);
	}
	
	public String getRoomId() {
		return _roomId;
	}
	
	public String getSentences() {
		return _sentenses;
	}

}
